package baseTest;

public class NumberTable {
    public static void main(String[] args) {
        int arr[] = {5, 6, 7, 8, 9, 10,11};
        int[] p = process(5, arr);
        for (int m : p) {
            System.out.println(m);
        }
    }

    public static int[] process(int n, int arr[]) {
        int[] res=new int[n];
        int k=arr[2]-arr[1];
            res[0] = (arr[0]-k)/2;
            res[1] = res[0]+k;
            int m=1;
            for (int i =1;i <arr.length;i++){
                if (arr[i]==res[m]+res[m-1]){
                    continue;
                }else {
                    res[++m]=arr[i]-res[0];
                }
                if (m>=n-1){
                    break;
                }
            }
        return res;
    }

}
